package com.blinddate.controller;

import com.blinddate.pojo.result.Result;
import com.blinddate.pojo.vo.UserInfVO;
import com.blinddate.service.RelevancyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


@RestController
@Slf4j
@RequestMapping("/user/relevancy")
@Api(tags = "用户查看关联")
public class RelevancyController {

    @Autowired
    private RelevancyService relevancyService;

    @GetMapping("/get_who_relevancy")
    @ApiOperation("获得谁看过我的信息")
    public Result<List<UserInfVO>> getWhoRelevancy(@RequestParam Integer page,@RequestParam Integer size){
        log.info("谁看过我的信息:{},{}",page,size);
        List<UserInfVO> whoUserInfo = relevancyService.getWhoUserInfo(page, size);
        if (whoUserInfo==null){
            return Result.error("获取列表失败");
        }
        if (whoUserInfo.size()==0){
            return Result.error("没有人解锁过你的信息");
        }
        return Result.success(whoUserInfo);
    }

    @GetMapping("/get_relevancy")
    @ApiOperation("我看过谁的信息")
    public Result<List<UserInfVO>> getRelevancy(@RequestParam Integer page,@RequestParam Integer size){
        log.info("看过谁的信息:{},{}",page,size);
        List<UserInfVO> userInfvoList = relevancyService.getUserInfo(page,size);
        if (userInfvoList==null){
            return Result.error("获取列表失败");
        }
        if(userInfvoList.size()==0){
            return Result.error("未解锁过用户信息");
        }
        return Result.success(userInfvoList);

    }

}
